/**
 * Created by zhaojm on 15/4/28.
 */
game.HeroLayer = cc.Layer.extend({
    _hero:null,
    _world:null,
    ctor:function(world){
        this._super();
        var winSize = cc.winSize;
        this._world = world;

        var hero = this._hero = new game.Box2dBall(cc.p(winSize.width * 0.2, winSize.height / 2 + 200));
        this.addRole(hero);



        this._listener = cc.EventListener.create({
            event: cc.EventListener.TOUCH_ONE_BY_ONE,
            swallowTouches: true,// true 为不向下传递
            onTouchBegan: function(touch, event){

                hero.bounce();
                return true;
            }
        });

        cc.eventManager.addListener(this._listener, this);

    },
    getHeroPos:function(){
        return this._hero.getPosition();
    },


    addRole:function(role){
        role.addToLayer(this, this._world);
    },

    gameOver:function(){
        cc.eventManager.removeListener(this._listener);
        this._hero.removeFromLayer();
    },
});